package com.wxy.h2;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Optional;

/**
 * 主程序入口
 */
@Slf4j
@SpringBootApplication
public class Application {

	public static void main(String[] args) throws UnknownHostException {
		ConfigurableApplicationContext context = SpringApplication.run(Application.class, args);
		Environment environment = context.getBean(Environment.class);
		String port = Optional.ofNullable(environment.getProperty("server.port")).orElse("8080");
		String path = Optional.ofNullable(environment.getProperty("server.servlet.context-path")).orElse("/");
		String host = Optional.ofNullable(InetAddress.getLocalHost().getHostAddress()).orElse("127.0.0.1");
		log.info("访问地址：http://{}:{}{}", host, port, path);
	}
}
